<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>proxy check result</title>
</head>
<body>
    <input type="checkbox" id="1"></input>1     
    <input type="checkbox" id="2"></input>2     
    <input type="checkbox" id="3"></input>3     
    <input type="checkbox" id="4"></input>4     
    <input type="checkbox" id="5"></input>5     
    <input type="checkbox" id="6"></input>6     
    <input type="checkbox" id="7"></input>7     
    <input type="checkbox" id="8"></input>8     
    <input type="checkbox" id="9"></input>9
</body>
<script type="text/javascript">
    const synchronousFile = id => console.log(id)

    const proxySynchronousFile = (() => {
        let cache = [], timer = null;

        return function (id) {
            cache.push(id)
            if (timer) {
                return
            }

            timer = setTimeout(() => {
                synchronousFile(cache.join(','))
                clearTimeout(timer)
                timer = null
                cache.length = 0
                cache = []
            }, 1000);
        }
    })()

    const checkBox = document.getElementsByTagName('input')

    for ( let i = 0; i < checkBox.length; i ++ ) {
        checkBox[i].onclick = function () {
            if (this.checked === true) {
                proxySynchronousFile(this.id)
            }
        }
    }
    
</script>
</html>